using System.Activities.Statements;
using Headsight.BPMN2WF.BPMN.Model;
using Headsight.BPMN2WF.BPMN.Schemas;
using Headsight.BPMN2WF.Testing;
using Headsight.BPMN2WF.Testing.TestObjCtors;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Headsight.BPMN2WF.Transformation.Transformers
{
    [TestClass]
    public class BPMN2WFTransformation_WriteLineTest
    {
        private BPMNFlowNode _bpmnFlowNode;
        private BPMN2WFTranformationTester _tester;
        private BPMN2WFTransformations4TestingCtor _bpmn2WfTransMappingsCtor;

        [TestInitialize]
        public void SetUp()
        {
            var tFlowElement = new tUserTask {id = "**id**", name = "**name**"};
            _bpmnFlowNode = new BPMNFlowNodeCtor().WithTFlowElement(tFlowElement).WithId("**id1**").Create();

            _bpmn2WfTransMappingsCtor = new BPMN2WFTransformations4TestingCtor()
                .WithDefault(typeof(BPMN2WFTransformationWriteLine));

            _tester = new BPMN2WFTranformationTester().With(_bpmn2WfTransMappingsCtor).Create();
        }

        [TestMethod]
        public void Transform_and_verf_real_workflow_behavior()
        {
            var sw = _tester.Transform(_bpmnFlowNode).Execute();
            
            Assert.AreEqual("**name**", sw.ToString().Replace("\n", "").Replace("\r", ""));
        }

        [TestMethod]
        public void Transform()
        {
            var actual = _tester.Transform(_bpmnFlowNode).BPMNTransformationResult;

            Assert.IsInstanceOfType(actual.Result, typeof(WriteLine));
            Assert.AreSame(actual.Result, actual.FlowIn);
            Assert.AreSame(actual.Result, actual.FlowOut);
        }
    }
}